package com.seedwill.common.meta.base;

import java.util.ArrayList;
import java.util.List;

import com.seedwill.common.meta.IData;
import com.seedwill.common.meta.IIdentity;

public class AData implements IData {

	protected List<IData> childDataList;
	
	protected List<IIdentity> aspectList;
	
	protected IData parentData;
	
	protected Object data;
	
	protected String wildCatetory;
	
	protected Object meta;
	
	@Override
	public void addChildData(IData childData) {
		if(childDataList == null){
			childDataList = new ArrayList<IData>();
		}
		childDataList.add(childData);
	}

	@Override
	public void cleanChildData() {
		if(childDataList != null){
			childDataList.clear();
		}
	}

	@Override
	public IData getSclarAspect(IIdentity aspectIdt) {
		if(aspectList != null){
			for(IIdentity d : aspectList){
				if(d.getIdentityVal().equals(aspectIdt.getIdentityVal()) && aspectIdt.getMeta().equals(d.getMeta())){
					return d;
				}
			}
		}
		return null;
	}
	public List<IData> getAspect(IIdentity aspectIdt) {
		List<IData> aspectL = null;
		if(aspectList != null){
			 aspectL = new ArrayList<IData>();;
			for(IIdentity d : aspectList){
				
				if(d.according(aspectIdt)){
					aspectL.add(d);
				}
			}
		}
		return aspectL;
	}
	@Override
	public Object getData() {
		return data;
	}

	@Override
	public String getWildCatetory() {
		return wildCatetory;
	}

	@Override
	public void removeChildData(IData childData) {
		if(childDataList != null){
			childDataList.remove(childData);
		}
	}

	@Override
	public void setData(Object data) {
		this.data = data;
	}

	@Override
	public void setWildCatetory(String cate) {
		this.wildCatetory = cate;
	}

	@Override
	public Object getMeta() {
		// TODO Auto-generated method stub
		return meta;
	}

	@Override
	public void setMeta(Object meta) {
		this.meta = meta;
	}

	public IData getParentData() {
		return parentData;
	}

	public void setParentData(IData parentData) {
		this.parentData = parentData;
	}

	public List<IData> getChildDataList() {
		return childDataList;
	}

	public void setChildDataList(List<IData> childDataList) {
		this.childDataList = childDataList;
	}

	public List<IIdentity> getAspectList() {
		return aspectList;
	}

	public void setAspectList(List<IIdentity> aspectList) {
		this.aspectList = aspectList;
	}

}
